package com.youdianda.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youdianda.entity.YddArticle;
import com.youdianda.entity.YddUser;
import com.youdianda.mapper.YddArticleMapper;
import com.youdianda.result.Result;
import com.youdianda.service.IYddArticleService;
import com.youdianda.service.UserMyArticleService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class UserMyArticleServiceImpl extends ServiceImpl<YddArticleMapper, YddArticle> implements UserMyArticleService {
    /**
     * 修改文章
     *
     * @param yddArticle
     * @return
     */
    @Override
    public Result updateArticle(YddArticle yddArticle) {
        boolean updateById = updateById(yddArticle);
        return Result.success(updateById);
    }

    /**
     * 发布文章
     *
     * @param yddArticle
     * @return
     */
    @Override
    public Result addArticle(YddArticle yddArticle) {
        yddArticle.setDefaultData("1");
        yddArticle.setCreateDate(System.currentTimeMillis());
        System.out.println("+++++++++++++++++"+save(yddArticle));

        return Result.success();
    }

    /**
     * 删除我的文章
     *
     * @param id
     * @return
     */
    @Override
    public Result deleteArticle(Integer id) {
        boolean removeById = removeById(id);
        return Result.success(removeById);
    }


}
